package com.hc.controller;

import com.hc.entity.QcEquipment;
import com.hc.model.QcMonitorModel;
import com.hc.model.QcRecordStatusModel;
import com.hc.service.QcMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;


/**
 * @author LiuZhiHao
 * @date 2019/8/28 14:08
 * 描述:
 **/
@RestController
@RequestMapping("/qcMonitor")
@Api(description = "监测记录")
public class QcMonitorController {

    @Autowired
    private QcMonitorService qcMonitorService;

    @PostMapping("")
    @ApiOperation("新增监测记录")
    public void saveQcMonitor(@RequestBody QcMonitorModel qcMonitorModel){
        qcMonitorService.saveQcMonitor(qcMonitorModel);
    }

    @GetMapping("/beforeMaintainTime/{eqId}")
    @ApiOperation("/获取常用仪器上次维护时间")
    public Date getbeforeMaintainTime(@PathVariable(value = "eqId") Integer eqId ){
        return  qcMonitorService.getbeforeMaintainTime(eqId);
    }

    @PostMapping("/findEqDeatil")
    @ApiOperation("查询设备巡检记录详情")
    public List<QcMonitorModel> findEqDeatil(@RequestBody QcRecordStatusModel qcRecordStatusModel){
        return qcMonitorService.findEqDeatil(qcRecordStatusModel);
    }


    @GetMapping("/getMonEq")
    @ApiOperation("查询监测设备 1显微镜 2工作台 3常用仪器 4气瓶")
    public List<QcEquipment> getMonEq(@RequestParam(value = "commonlyUsed") Integer commonlyUsed,
                                      @RequestParam(value = "enable",required = false) String enable){
        return qcMonitorService.getMonEq(commonlyUsed,enable);
    }


    @GetMapping("/exportExcel")
    @ApiOperation("导出巡检记录excel")
    public void exportExcel(HttpServletResponse response, QcRecordStatusModel qcRecordStatusModel){
        qcMonitorService.exportExcel(response,qcRecordStatusModel);
    }

    @GetMapping("/addIsAddLiquidNitrogen")
    @ApiOperation("添加是否添加液氮的维护记录")
    public void addIsAddLiquidNitrogen(@ApiParam(name = "eqId", value = "设备id")
                                       @RequestParam("eqId") Integer eqId) {
        qcMonitorService.addIsAddLiquidNitrogen(eqId);
    }

}


